<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/amend_code.css"/>
		<link rel="stylesheet" type="text/css" href="css/app.css"/>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript">
			mui.init()
		</script>
		<style type="text/css">
			.mui-content{margin-top: 45px;}
			/*.mui-input-group .mui-input-row input{padding: 13px 15px;}*/
			.mui-icon-clear{top: 20px!important;}
		</style>
	</head>

	<body>
		<div id="headerNav"></div>
		<div class="mui-content">
		    <div class="mui-input-group" id="checkInputVal">
			    <div class="mui-input-row">
			        <input type="text" class="mui-input" placeholder="输入当前支付密码" id="phoneTest" style="width: 70%;">
			        
			    </div>
			    <div class="mui-input-row">
			        <input type="password" class="mui-input-clear" placeholder="请输入新的支付密码" id="new_pass">
			    </div>
			    <div class="mui-input-row">
			        <input type="password" class="mui-input-clear" placeholder="请再次确认新的支付密码" id="new_pass1">
			    </div>
			</div>
			<div class="mui-button-row" style="margin: 20px 0;">
				<button type="submit" class="mui-btn btnColor mui-col-sm-11 mui-col-xs-11 mui-of" id="btn">完成</button>
			</div>
		</div>
		
	</body>
	<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
		$('#headerNav').load('header.html',function(){
			$('header h1').html('修改支付密码');
		});
		
	</script>
	<script type="text/javascript">
		$("#btn").click(function(){
				var a = window.localStorage.state;
				var b = window.localStorage.data;
				var phoneTest = $("#phoneTest").val();
				var new_pass = $("#new_pass").val();
				console.log(b);
				var tests = /^\d{6}$/;
				var mima = $("#new_pass").val();
				var mima1 = $("#new_pass1").val();
				
				if(tests.test(mima) && tests.test(mima1)){
					console.log(phoneTest)
					console.log(new_pass)
					
					$.ajax({
						type: "post",
						url: "http://mall.itcn99.com/i/index/edit_pay_pass",
						dataType: "jsonp",
						async: true,
						data: {
							"uid":b,
							"pay_pass":phoneTest,
							"new_paypass":new_pass,
						},
						success: function(data) {
							console.log(data);
							if(data.state == 0){
								mui.alert("","密码修改失败")
							}else if(data.state == 1){
								mui.alert("","密码修改成功",function(){
						             window.location.href="payment.html"
								})
							}else if(data.state == 2){
								mui.alert("","网络超时，请重新更改")
							}else if(data.state == 3){
								mui.alert("","密码错误，请重新输入")
							}else if(data.state == 4){
								mui.alert("","数据为空,联系前台传入数据")
							}
						}
					})
				}
		    	
		})

	</script>
</html>